<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        var res = [4, 3, 2, 7, 8, 2, 3, 1]
        var sum = []
        for (var i = 0; i < 9; i++) {
            if (res.indexOf(i) === -1) {
                sum.push(i)
            }
        }
        console.log(sum)
    </script>
</body>

</html>